class Solution {
public:
    int cuttingRope(int n) {
        if(n == 2) return 1;
        if(n == 3) return 2;
        vector<int> dp(n+1,0);
        dp[2] = 1;
        dp[3] = 2;
        for(int i = 4;i <= n;i++){
            for(int j = 1;j <= i/ 2;j++){
                int x = i - j;
                dp[i] = max(dp[i],max(dp[x],x) * max(dp[j],j));
            }
        }
        return dp[n];
    }
};
